﻿using Myotragus.Data;
using NHibernate;

namespace Myotragus.Store.Model.Tests.Services
{
  public class SingleSessionFactoryAdapter : Service, ISessionFactoryAdapter
  {
    ISessionFactory _factory;
    ISession _session;

    #region ISessionFactoryAdapter Members

    public ISessionFactoryAdapter SetFactory(ISessionFactory factory)
    {
      _factory = factory;
      return this;
    }

    public ISession OpenSession()
    {
      return _session ?? (_session = _factory.OpenSession());
    }

    #endregion
  }


}
